module.exports = function(app,entitys,loginRouter,db){
   //用户详情
   app.get('/product',loginRouter, async (req, res) => {
    res.send(await entitys.product.getById(req.query.id))
  })
  //商品列表分页查询
  app.get('/product/list',loginRouter, async (req, res) => {
    let key = req.query.key || '' //按关键字查询
    res.send(await db.query(
      `select * from book where id like "%${key}%";`,
      req.query.pageNum,
      req.query.pageSize
      ))
  })
   //商品新增
   app.post('/product',loginRouter, async (req, res) => {
    res.send(await entitys.product.insert(req.body))
  })
  //商品修改
  app.put('/product',loginRouter, async (req, res) => {
    res.send(await entitys.product.updateById(req.body))
  })
  //商品删除
  app.delete('/product',loginRouter, async (req, res) => {
    res.send(await entitys.product.deleteById(req.query.id))
  })
}
